<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>oo-2</title>
</head>
<body>

</body>
<script>


    /*
     *  prototype 在函数的定义阶段被创建一次
     *
    * */
  /*  function Employee() {
    }

    Employee.prototype.name = "L";
    Employee.gender="female";

    Employee.prototype.display =function () {
        alert("name："+this.name);
    }

  let employee1=  new Employee();

   employee1.display();*/

   /*
     * 组合模式： 构造器和原型结合
     *    1. 在构造器上创建属性
     *    2. 在函数原型上创建方法
   * */
     function Employee(name,age,gender) {
        this.name = name;
        this.gender=gender;
        this.age=age;
    }

    Employee.prototype.display=function () {
        alert("name:"+this.name+";age:"+this.age+";gender:"+this.gender);
    }

   let employee1= new Employee("L",34,'male');
    employee1.display();



</script>

</html>